﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IngredSubTool
{
    public class Session
    {
        public String searchTerm { get; set; }
        public BookmarkView currentBookmark { get; set; }

        public Substitution selectedSub { get; set; }

        public List<Substitution> bookmarkSubs = new List<Substitution>();

        public List<SubmittedSubstitution> submittedSubs = new List<SubmittedSubstitution>();

        // flag to determine what page to go back to
        public int homePage = 0;
        public int searchResultPage = 1;
        public int mySubPage = 2;
        public int recentSubPage = 3;
        public int bookmarkPage = 4;

        //public int previousPage = 0;

        public System.Windows.Controls.UserControl lastPage;

        public System.Windows.Controls.UserControl currentPage;

        public LinkedList<System.Windows.Controls.UserControl> previousPagesList = new LinkedList<System.Windows.Controls.UserControl>();
      

        public void addToPrevPageList(System.Windows.Controls.UserControl page)
        {
            if (previousPagesList == null)
            {
                previousPagesList.AddFirst(new SearchView());
           
            }
            else
            {
                previousPagesList.AddLast(page);
            }
    }
        public void removeFromPrevPageList()
        {
            if(previousPagesList != null)
            {
                previousPagesList.RemoveLast();
            }
        }
        public System.Windows.Controls.UserControl getPrevPage()
        {
            if (previousPagesList != null)
            {
                return (System.Windows.Controls.UserControl)previousPagesList.Last.Value;
               
            }
            else
            {
                return new SearchView();
            }
        }



    }
}
